package org.ccams.dao;

import java.util.List;

import org.ccams.domain.TMaterielStock;
import org.ccams.util.PageParameter;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class TMaterielStockDAO  extends SqlMapClientDaoSupport{
	/**
	 * 返回指定条件的库存信息
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<TMaterielStock> getTMaterielStockByPage(PageParameter page){
		return getSqlMapClientTemplate().queryForList("t_materielstock.getTMaterielStockByPage", page);
	}
	/**
	 * 返回指定条件的记录数
	 * @param page
	 * @return
	 */
	public int getCount(PageParameter page){
		return (Integer)getSqlMapClientTemplate().queryForObject("t_materielstock.getCount", page);
	}
	/**
	 * 库存中是否已经有这个物料的信息
	 * @param tms
	 * @return
	 */
	public int getIdtStock(TMaterielStock tms){
		return (Integer) getSqlMapClientTemplate().queryForObject("t_materielstock.getIdtStock",tms);
	}
	/**
	 * 物料库存数量
	 * @param tms
	 * @return
	 */
	public int getStockAmount(TMaterielStock tms){
		return (Integer) getSqlMapClientTemplate().queryForObject("t_materielstock.getStockAmount",tms);
	}
	/**
	 * 往库存中插入数据
	 * @param tms
	 * @return
	 */
	public int insertTMaterielStock(TMaterielStock tms) {
		return getSqlMapClientTemplate().update("t_materielstock.insertTMaterielStock",tms);
	}
	
	/**
	 *更新库存数量
	 *@param tms
	 *@return
	 */
	public int updateStockAmount(TMaterielStock tms){
		return getSqlMapClientTemplate().update("t_materielstock.upateStockAmount",tms);
	}
	
	/**
	 * 库存数量为0时，删除此条数据
	 */
//	public int deleteTMaterielStock(TMaterielStock tms){
//		return getSqlMapClientTemplate().delete("t_materielstock.upateStockAmount",tms);
//	}
}
